class Solution {
public:
     int evalRPN(vector<string>& tokens) {
        stack<int>st;
        for(auto &s:tokens)
        {
            if(s.size()==1)//表示符号
            {
                if(s[0]=='-'||s[0]=='*'||s[0]=='+'||s[0]=='/')
                {
                    int right=st.top();
                    st.pop();
                    int left=st.top();
                    st.pop();
                    switch (s[0])
                    {
                        case '-':
                            st.push(left-right);
                            break;
                        case '+':
                            st.push(left+right);
                            break;
                        case '*':
                            st.push(left*right);
                            break;
                        case '/':
                            st.push(left/right);
                            break;
                    }
                    
                }
                else
                    st.push(stoi(s));

            }
            else {
                st.push(stoi(s));
            }
        }
        return st.top();
    }
};